package adv41;

import adv330.FileRead;

import java.io.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class ResetIO {
    //带了缓冲的流才能回头
    public static void main(String[] args) {
        //BufferedInputStream
        //  BufferedOutputStream o
        try {
            BufferedReader fin = new BufferedReader(new FileReader("d:/temp/java83.txt"));
            System.out.println(fin.markSupported());
            for (int i = 0; i < 20; i++) {
                System.out.println(fin.readLine());
            }
            System.out.println("读完二十行,做了个标记");
            fin.mark(1024 * 1024);
            String str = null;
            while ((str = fin.readLine()) != null) {
                System.out.println(str);
            }
            System.out.println("回来，按任意键继续：");
            System.in.read();
            fin.reset();
            System.out.println("回到了读了二十行后的地方:");
            System.out.println("继续读");
            while ((str = fin.readLine()) != null) {
                System.out.println(str);
            }
            fin.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
